button.setOnClickListener(object : View.OnClickListener {
override fun onClick(v: View?) {
//your implementation goes here
}
})
// get reference to button
val btn_click_me = findViewById(R.id.btn_click_me) as Button
// set on-click listener
btn_click_me.setOnClickListener {
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
}